package com.kodcu.web.training;

import com.kodcu.web.SkeletonPage;
import com.kodcu.web.menubar.Menu;
import com.kodcu.web.training.content.*;
import com.kodcu.web.training.leftmenupanel.LeftMenuPanel;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.ResourceModel;

public class TrainingPage extends SkeletonPage {

    public TrainingPage() {
        Label title = (Label) this.get("title");
        title.setDefaultModel(new ResourceModel("title.egitim"));

        this.decorate(null);
        TrainingMainPanel rightSide = new TrainingMainPanel("RightSide", null);
        add(rightSide);
    }

    public TrainingPage(PageParameters params) {
        this.decorate(params);

        String trainingId = "1000"; // go to default config
        try {
            trainingId = params.getString("0");
        } catch (Exception ex) {
        }

        Label title = (Label) this.get("title");
        if (trainingId.equalsIgnoreCase("java-egitimleri")) {
            title.setDefaultModel(new ResourceModel("title.egitim"));
            TrainingMainPanel bilgiPanel = new TrainingMainPanel("RightSide", null);
            add(bilgiPanel);
        } else if (trainingId.equalsIgnoreCase("kodcu-com-java-egitimlerine-kayit")) {
            title.setDefaultModel(new ResourceModel("title.egitim"));
            KayitPanel kayitPanel = new KayitPanel("RightSide");
            add(kayitPanel);
        } else if (trainingId.equalsIgnoreCase("java-programlama-dili-egitimi")) {
            title.setDefaultModel(new ResourceModel("title.egitim.temel.java"));
            JavaTrainingPanel jtp = new JavaTrainingPanel("RightSide", null);
            add(jtp);
        } else if (trainingId.equalsIgnoreCase("nesneye-yonelik-tasarim-ve-tasarim-kaliplari-egitimi")) {
            title.setDefaultModel(new ResourceModel("title.egitim.tasarim.kalibi"));
            NesneyeYonelikTasarimPanel nyt = new NesneyeYonelikTasarimPanel("RightSide", null);
            add(nyt);
        } else if (trainingId.equalsIgnoreCase("apache-wicket-spring-egitimi")) {
            title.setDefaultModel(new ResourceModel("title.egitim.wicket"));
            ApacheWicketPanel aw = new ApacheWicketPanel("RightSide", null);
            add(aw);
        } else if (trainingId.equalsIgnoreCase("google-guice-egitimi")) {
            title.setDefaultModel(new ResourceModel("title.egitim.guice"));
            GoogleGuicePanel gg = new GoogleGuicePanel("RightSide");
            add(gg);
        } else if (trainingId.equalsIgnoreCase("java-egitmenler")) {
            title.setDefaultModel(new ResourceModel("title.java.egitmen"));
            EgitmenlerPanel egitmenlerPanel = new EgitmenlerPanel("RightSide");
            add(egitmenlerPanel);

        } else {
            title.setDefaultModel(new ResourceModel("title.egitim"));
            TrainingMainPanel bilgiPanel = new TrainingMainPanel("RightSide", null);
            add(bilgiPanel);
        }


    }

    private void decorate(PageParameters params) {
        // indicator for the top menu
        PageParameters paramsForMenu = new PageParameters();
        paramsForMenu.add("0", "Egitimler");
        Menu menu = new Menu("Menu", paramsForMenu);
        add(menu);
        // ends

        // adds left menu
        LeftMenuPanel leftMenu = new LeftMenuPanel("LeftMenu", params);
        add(leftMenu);
    }

}
